package com.nlp.visualization.dao.impl.backend;

import com.nlp.visualization.dao.backend.IApiCountDao;
import com.nlp.visualization.dao.base.DaoSupportImpl;
import com.nlp.visualization.pojo.db.TApiStatistics;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author LXM
 * @Title: NLPVisualizationTools
 * @Description:
 * @date 2018/5/16下午3:21
 */
@Repository
public class ApiCountDaoImpl extends DaoSupportImpl<TApiStatistics> implements IApiCountDao {

    /**
     * 根据时间的起点和重点查询
     *
     * @param start
     * @param end
     * @return
     */
    @Override
    public List countByTime(long start, long end) {


        String sql = "SELECT name,COUNT(*)   FROM t_api_statistics WHERE t_api_statistics.time > " + start + " and t_api_statistics.time < " + end + " GROUP  BY t_api_statistics.name ";
        Query query = getSession().createSQLQuery(sql);
        List list = query.list();

        return list;

    }
}
